﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;

/*
using Microsoft.Dynamics.GP.eConnect.Serialization;
using System.Xml.Serialization;
using Microsoft.Dynamics.GP.eConnect;
using System.Xml;
using System.IO;
*/

/* CHANGELOG: 
 * 
 *  - jbsolomon 5/15/11 6:30p
 *    changed namespace
 *    using System.data and System.Data.SqlClient for DatabaseConnection objects
 *    beginning to add databaseconnection
 * 
 *  - jbsolomon 5/17/11 4:30p
 *    added SqlConnection string from Ctrl Panel -> Administrative Tools -> IIS -> Connection Strings
 *    removed SqlConnection, etc
 *    using eConnect now
 */

/* TODO:
 *  James Solomon: CardTypeList.xslt, CardTypeList.xml, GetCardTypes( )
 *    - Query: SELECT CARDNAME FROM SY03100
 *  David Liman: LookupItems( )
 *    - Query: SELECT a.ITEMNMBR, a.ITEMDESC, a.ITMSHNAM, a.SELNGUOM, b.QTYONHND, c.LISTPRCE
 *    - FROM IV00101 a 
 *    - INNER JOIN IV00102 b ON a.ITEMNMBR = b.ITEMNMBR 
 *    - INNER JOIN IV00105 c ON a.ITEMNMBR = c.ITEMNMBR
 *    - WHERE b.RCRDTYPE = 1 AND a.ITEMNMBR = <ItemID>
 *  Brian Droncheff: UoM
 *    - Method Name: GetUOM
 *    - Assigned To: Brian 
 *    - Query: SELECT ITEMNMBR, UOFM, UOMPRICE FROM IV00108 WHERE ITEMNMBR = <itemID>
 */

namespace MobileSalesWS
{
    /// <summary>
    /// Summary description for User
    /// </summary>
    [WebService(Namespace = "http://www.albaspectrum.com/WS")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]



    public class User : System.Web.Services.WebService
    {

        #region :: Public Methods ::

        [WebMethod]
        public bool Login(string loginID, string password)
        {
            try
            {
                System.Data.SqlClient.SqlConnection dbConn = Utils.OpenDBConnection(loginID, password);
                if ((dbConn.State != System.Data.ConnectionState.Closed) || 
                    (dbConn.State != System.Data.ConnectionState.Broken))
                {
                    dbConn.Close();
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        [WebMethod]
        public bool Logout()
        {
            try
            {
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        [WebMethod]
        public string GetErrorMessage()
        {
            try
            {
                return string.Empty;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

        #endregion :: Public Methods ::
    }
}
